package ref;

import java.lang.reflect.Field;

/**
 * @author Mark
 * @date 2020/5/24 23:10
 * @description 类信息
 */
public class ClassInfo {

    public static void main(String[] args) throws ClassNotFoundException {

        Class<?> aClass = Class.forName("ref.User");
        String name = aClass.getName();
        System.out.println("name = " + name);
        System.out.println("aClass.getSimpleName() = " + aClass.getSimpleName());

        // public 属性
        Field[] fields = aClass.getFields();
        for (Field field : fields) {
            System.out.println("field = " + field);

        }

        // 全部属性(private)
        Field[] declaredFields = aClass.getDeclaredFields();
        for (Field declaredField : declaredFields) {
            System.out.println("declaredField = " + declaredField);
        }
    }

}
